/**
 * 保存当前用户一系列项目信息
 */

import {defineStore} from 'pinia'
import {ref} from 'vue'
import {getProjectInfo} from '@/api/student/project'

export const useProjectStore = defineStore(
    'student-project',
    () => {
        const projectInfo = ref({})
        const projectData = ref({})
        const projectName = ref('')
        const courseName = ref('')
        const className = ref('')
        const getProjectInfoFunc = async () => {
            const res = await getProjectInfo()
            projectInfo.value = res.data.data
        }
        const setProjectData = (data) => {
            projectData.value = data
        }
        const setProjectName = (name) =>{
            projectName.value = name
        }
        const getProjectName = () =>{
            return projectName.value
        }
        const setCourseName = (name) => {
            courseName.value = name
        }
        const getCourseName = () => {
            return courseName.value
        }

        const setClassName = (name) => {
            className.value = name
        }
        const getClassName = () => {
            return className.value
        }
        const setProjectNull = () =>{
            projectName.value = ref('')
        }
        return {
            projectInfo,
            projectData,
            projectName,
            courseName,
            className,
            getProjectInfoFunc,
            setProjectData,
            setProjectName,
            getProjectName,
            setCourseName,
            getCourseName,
            setClassName,
            getClassName,
            setProjectNull
        }

    },
    {
        persist: true
    }
)

